package com.llu.demo.enums;

import lombok.Getter;

/**
 * @author jackliu  Email:
 * @description: 返回的枚举code
 * @Version
 * @create 2024-06-23 22:06
 */
@Getter
public enum ResultCodeEnum {

    SUCCESS(200,"成功"),
    FAILED(500,"失败"),
    UNAUTHORIZED(401,"未认证"),
    NOT_FOUND(404,"未找到"),
    SERVER_ERROR(500,"服务器错误");

    private Integer code;
    private String message;

    ResultCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }



    public static ResultCodeEnum getEnumByCode(Integer codeVal) {
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()) {
            if (resultCodeEnum.code.equals(codeVal)) {
                return resultCodeEnum;
            }
        }
        return null;
    }



}
